#include "database.h"
#include "MyGame.h"

int Quit(bool pause = false, const string &reason = "") {
	PhysicsSystem::Destroy();
	Window::Destroy();
	Renderer::Destroy();

	if(pause) {
		std::cout << reason << std::endl;
		system("PAUSE");
	}

	return 0;
}

int main() {

	Window::Initialise("Battleship", 1280,720,false);
	Renderer::Initialise();
	PhysicsSystem::Initialise();
	
	MyGame* game =new MyGame();
	game->Init();

	Window::GetWindow().LockMouseToWindow(true);
	Window::GetWindow().ShowOSPointer(false);

	while(Window::GetWindow().UpdateWindow() && !Window::GetKeyboard()->KeyDown(KEYBOARD_ESCAPE)){
		float msec = Window::GetWindow().GetTimer()->GetTimedMS();	
		game->UpdateCore(msec);
		game->UpdateGame(msec);
	}
	delete game;
	return Quit();
}
